package com.example.leetcode.tree;

import com.example.leetcode.tree.common.TreeNode;
import com.example.leetcode.tree.common.TreeUtils;

/**
 * AC
 */
class Solution106{
    public TreeNode buildTree(int[] inorder, int[] postorder) {

        return TreeUtils.buildTreeByPostAndInOrder(postorder, 0, postorder.length - 1, inorder, 0, inorder.length - 1);

    }
}

/**
 * 106. 从中序与后序遍历序列构造二叉树
 */
public class leetcode106 {

    public static void main(String[] args) {

        int[] inorder = {9,3,15,20,7};
        int[] postorder = {9,15,7,20,3};

//        int[] preorder = {1, 2};
//        int[] inorder = {2, 1};

        Solution106 solution106 = new Solution106();

        TreeNode root = solution106.buildTree(inorder, postorder);

        TreeUtils.treeBFSTraverseWithLevelInfo(root);

    }
}
